subroutine abort(message)
  use logs
  use my_mpi
  implicit none
  character(*), intent(in) :: message
  integer ierr

  write(logunit,*)
  write(logunit,*)" GridHDF5 ABORT "//message
  write(logunit,*)
  call flush(logunit)

  call endrun()
 
  stop
end subroutine abort

! --------------------------------------------------------------------

subroutine endrun()
  use logs
  use my_mpi

  write(logunit,*)''
  write(logunit,*)' -Shutting down MPI and ending code'
  write(logunit,*)''
  call flush(logunit)
#ifdef ONE_LOG 
  if(MyPE /= 0) close(logunit)
#else
  close(logunit)
#endif
  call mpi_finalize(ierr)

end subroutine endrun

